﻿using System.Threading.Tasks;
using RAP.Framework.Libary.DataSource;
using System.Collections;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using RAP.Web.Libary.Controller;
using RAP.Web.Core.Server.Service.Test;
using RAP.Framework.Libary.Utils;

namespace RAP.Web.Core.Controllers
{
  /// <summary>
  /// TestController
  /// </summary>
  public class TestController : APIControllerBase
  {
    public TestController( ) { }

    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    [HttpGet]
    public async Task<object> TestLazyLoadQuery( [FromServices] TestService testService )
    {
      return await testService.TestLazyLoadQuery( QueryParams );
    }

    [HttpGet]
    public async Task<object> TestDynamic( [FromServices] TestService testService )
    {
      return await testService.TestDynamic( QueryParams );
    }

    [HttpGet]
    public async Task<object> TestIfElse(
      [FromServices] TestService testService,
      //限制键值对对象中的type参数的类型为整形
      int type = 0
      )
    {
      return await testService.TestIfElse( QueryParams );
    }

    [HttpGet]
    public async Task<object> TestScript(
      [FromServices] TestService testService,
      //限制键值对对象中的type参数的类型为整形
      int type = 0
      )
    {
      return await testService.TestScript( QueryParams );
    }

    [HttpGet]
    public async Task<object> TestRunExpression(
      [FromServices] TestService testService,
      //限制键值对对象中的id参数的类型为整形
      int id = 0
      )
    {
      return await testService.TestRunExpression( QueryParams );
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="testService"></param>
    /// <returns></returns>
    public async Task<object> TestRelatedQuery( [FromServices] TestService testService )
    {
      return  await testService.Test_Related_Query( QueryParams );
    }

    public async Task<object> TestAttrs([FromServices] TestService testService)
    {
      return await testService.TestAttrs(QueryParams);
    }
  }
}
